package lab02.test33;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by V555 on 2017/11/18.
 */
public class Test {
    public static void main(String[] args) {
        //从控制台输入若干个单词（输入回车结束）放入集合中
        List<String> string = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        System.out.println("please input words:");
        String words = scanner.nextLine();
        //将这些单词排序后（忽略大小写）打印出来
        String[] x = words.split(" ");

        for (int i = 0; i < x.length; i++) {
            for (int j = i + 1; j < x.length; j++) {
                if (x[i].compareToIgnoreCase(x[j]) > 0) {
                    words = x[i];
                    x[i] = x[j];
                    x[j] = words;
                }
            }
        }
        System.out.println("排序后的单词：");
        for (String m:x){
            string.add(m);
            System.out.println(m);
        }
    }
}
